<template>
	<view>
		<u-tabbar
			:value="value"
			@change="change"
			:fixed="true"
			:placeholder="false"
			:safeAreaInsetBottom="true"
		>
		<template v-for="(item,index) in menuList" >
			<u-tabbar-item :text="item.name" :name="item.path" :key="index" :icon="item.icons">
				<!-- <image
							class="u-page__item__slot-icon"
							slot="active-icon"
							style="width: 50upx;height: 50upx;"
							:src="item.iconActive"
						></image>
						<image
							class="u-page__item__slot-icon"
							slot="inactive-icon"
							style="width: 50upx;height: 50upx;"
							:src="item.icon"
						></image> -->
			</u-tabbar-item>
			</template>
		</u-tabbar>
	</view>
</template>

<script>
import {menuList} from './menu.js'
	export default {
		name:"footerbar",
		data() {
			return {
				value:0,
				menuList:[],
			}
		},
		mounted() {
				this.getData()
		},
		methods:{
			getData(){
				this.https('/client/getFunctionState', {}).then(res => {
					if (res.status == 200) {
						menuList.map(item=>{
							if(res.data.isOpenGpt > 0 && item.path == 'pages/index/index'){
								item.hidden = false
							}
							uni.setStorageSync('isOpenGpt',res.data.isOpenGpt)
							if(res.data.isOpenGptOfficial > 0){
								item.hidden = false
							}
							if(res.data.isOpenSd > 0){
								item.hidden = false
							}
							if(res.data.isOpenMj > 0 ){
								item.hidden = false
							}
						})
						this.menuList = menuList.filter(m=>{
							return m.hidden == false
						})
						let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
						this.value =  routes[routes.length - 1].route // 获取当前页面路由，也就是最后一个打开的页面路由
					}
				})
			},
			change(e){
				console.log(e)
				uni.switchTab({
					url:'/'+ e
				})
			}
		}
	}
</script>